package com.example.day41_opengl_camera1;

import android.opengl.GLSurfaceView;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    private GLSurfaceView glSurfaceView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
    }

    private void initView(){
        glSurfaceView = findViewById(R.id.glsv_camera);
        //设置opengl版本
        glSurfaceView.setEGLContextClientVersion(2);
        //实现renderer  renderer告诉opengl我们怎么渲染
        glSurfaceView.setRenderer(new TriangleRender());
        //设置手动刷新
        /*渲染方式，RENDERMODE_WHEN_DIRTY表示被动渲染，只有在调用requestRender或者
        onResume等方法时才会进行渲染。RENDERMODE_CONTINUOUSLY表示持续渲染*/
        glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        //开始使用  执行这句代码后再onDrawFrame中使用
        glSurfaceView.requestRender();
    }

}
